    //
//  MainMenuViewController_iPad.m
//  Pepperdine
//
//  Created by Michael Coats on 3/16/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//


#import "MainMenuViewController_iPad.h"
#import "MapAppViewController_iPad.h"
#import "WavenetAppViewController_iPad.h"
#import "CafeAppViewController_iPad.h"
#import "LibraryAppViewController_iPad.h"
#import "DivisionAppViewController_iPad.h"
#import "AthleticsAppViewController_iPad.h"
#import "ConvoAppViewController_iPad.h"
#import "CalendarAppViewController_iPad.h"
#import "FacultyAppViewController_iPad.h"
#import "StudentActivitiesAppViewController_iPad.h"

#import "TemplateAppViewController_iPad.h"

int numberOfPages_iPad = 2;

@implementation MainMenuViewController_iPad

@synthesize pageControl, scrollView;

@synthesize mapAppViewController_iPad;
@synthesize cafeAppViewController_iPad;
@synthesize wavenetAppViewController_iPad;
@synthesize libraryAppViewController_iPad;
@synthesize divisionAppViewController_iPad;
@synthesize athleticsAppViewController_iPad;
@synthesize convoAppViewController_iPad;
@synthesize calendarAppViewController_iPad;
@synthesize facultyAppViewController_iPad;
@synthesize studentActivitiesAppViewController_iPad;
@synthesize tempAppViewController_iPad;

- (void)viewDidLoad {
	[super viewDidLoad];
	self.title = @"Main Menu";
	UINavigationBar *bar = [self.navigationController navigationBar];
	[bar setTintColor:[UIColor orangeColor]];
	
	[self.view setBackgroundColor:
     [UIColor colorWithPatternImage:
      [UIImage imageWithContentsOfFile:
       [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:
        @"background.png"]]]];
	
    [super viewDidLoad];
	scrollView.pagingEnabled = YES;
	[scrollView setContentSize:CGSizeMake((numberOfPages_iPad* 768.0f), 1.0f)];
	scrollView.showsHorizontalScrollIndicator = NO;
    scrollView.showsVerticalScrollIndicator = NO;
	scrollView.delegate = self;
	
	//pageControl.numberOfPages = numberOfPages_iPad;
	pageControl.currentPage = 0;
	[pageControl addTarget:self action:@selector(pageTurn:) forControlEvents:UIControlEventValueChanged];
	
	
	UIButton *mapAppButton = [[UIButton alloc] init];
	NSString *mapAppPath = [[NSBundle mainBundle] pathForResource:@"map_icon" ofType:@"png"];
	UIImage *mapAppImage = [UIImage imageWithContentsOfFile:mapAppPath];
	mapAppButton.frame = CGRectMake(20, 20, 80, 80);
	[mapAppButton setImage:mapAppImage forState:UIControlStateNormal];
	[scrollView addSubview:mapAppButton];
	[mapAppButton addTarget:self action:@selector(OpenMapApp_iPad:) forControlEvents:UIControlEventTouchUpInside];
	[mapAppImage release];
	[mapAppPath release];
	
	UILabel *mapAppLabel = UILabel.new;
	mapAppLabel.frame = CGRectMake(26, 105, 80, 20);
	[scrollView addSubview:mapAppLabel];
	mapAppLabel.text = @"Map";
	mapAppLabel.textAlignment = UITextAlignmentCenter;
	mapAppLabel.backgroundColor = [UIColor clearColor];
	
	UIButton *wavenetAppButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	wavenetAppButton.frame = CGRectMake(132, 20, 80, 80);
	[scrollView addSubview:wavenetAppButton];
	[wavenetAppButton addTarget:self action:@selector(OpenWavenetApp_iPad:) forControlEvents:UIControlEventTouchUpInside];
	
	UILabel *wavenetAppLabel = UILabel.new;
	wavenetAppLabel.frame = CGRectMake(132, 105, 80, 20);
	[scrollView addSubview:wavenetAppLabel];
	wavenetAppLabel.text = @"Wavenet";
	wavenetAppLabel.textAlignment = UITextAlignmentCenter;
	wavenetAppLabel.backgroundColor = [UIColor clearColor];
	
	UIButton *cafeAppButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	cafeAppButton.frame = CGRectMake(238, 20, 80, 80);
	[scrollView addSubview:cafeAppButton];
	[cafeAppButton addTarget:self action:@selector(OpenCafeApp_iPad:) forControlEvents:UIControlEventTouchUpInside];
	
	UILabel *cafeAppLabel = UILabel.new;
	cafeAppLabel.frame = CGRectMake(238, 105, 80, 20);
	[scrollView addSubview:cafeAppLabel];
	cafeAppLabel.text = @"Cafe";
	cafeAppLabel.textAlignment = UITextAlignmentCenter;
	cafeAppLabel.backgroundColor = [UIColor clearColor];
	
	UIButton *libraryAppButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	libraryAppButton.frame = CGRectMake(344, 20, 80, 80);
	[scrollView addSubview:libraryAppButton];
	[libraryAppButton addTarget:self action:@selector(OpenLibraryApp_iPad:) forControlEvents:UIControlEventTouchUpInside];
	
	UILabel *libraryAppLabel = UILabel.new;
	libraryAppLabel.frame = CGRectMake(344, 105, 80, 20);
	[scrollView addSubview:libraryAppLabel];
	libraryAppLabel.text = @"Library";
	libraryAppLabel.textAlignment = UITextAlignmentCenter;
	libraryAppLabel.backgroundColor = [UIColor clearColor];
	
	UIButton *divisionAppButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	divisionAppButton.frame = CGRectMake(450, 20, 80, 80);
	[scrollView addSubview:divisionAppButton];
	[divisionAppButton addTarget:self action:@selector(OpenDivisionApp_iPad:) forControlEvents:UIControlEventTouchUpInside];
	
	UILabel *divisionAppLabel = UILabel.new;
	divisionAppLabel.frame = CGRectMake(450, 105, 80, 20);
	[scrollView addSubview:divisionAppLabel];
	divisionAppLabel.text = @"Divisions";
	divisionAppLabel.textAlignment = UITextAlignmentCenter;
	divisionAppLabel.backgroundColor = [UIColor clearColor];
	
	UIButton *athleticsAppButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	athleticsAppButton.frame = CGRectMake(556, 20, 80, 80);
	[scrollView addSubview:athleticsAppButton];
	[athleticsAppButton addTarget:self action:@selector(OpenAthleticsApp_iPad:) forControlEvents:UIControlEventTouchUpInside];
	
	UILabel *athleticsAppLabel = UILabel.new;
	athleticsAppLabel.frame = CGRectMake(556, 105, 80, 20);
	[scrollView addSubview:athleticsAppLabel];
	athleticsAppLabel.text = @"Athletics";
	athleticsAppLabel.textAlignment = UITextAlignmentCenter;
	athleticsAppLabel.backgroundColor = [UIColor clearColor];
	
	UIButton *convoAppButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	convoAppButton.frame = CGRectMake(662, 20, 80, 80);
	[scrollView addSubview:convoAppButton];
	[convoAppButton addTarget:self action:@selector(OpenConvoApp_iPad:) forControlEvents:UIControlEventTouchUpInside];
	
	UILabel *convoAppLabel = UILabel.new;
	convoAppLabel.frame = CGRectMake(662, 105, 80, 20);
	[scrollView addSubview:convoAppLabel];
	convoAppLabel.text = @"Convo";
	convoAppLabel.textAlignment = UITextAlignmentCenter;
	convoAppLabel.backgroundColor = [UIColor clearColor];
	
	UIButton *calendarAppButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	calendarAppButton.frame = CGRectMake(26, 130, 80, 80);
	[scrollView addSubview:calendarAppButton];
	[calendarAppButton addTarget:self action:@selector(OpenCalendarApp_iPad:) forControlEvents:UIControlEventTouchUpInside];
	
	UILabel *calendarAppLabel = UILabel.new;
	calendarAppLabel.frame = CGRectMake(26, 215, 80, 20);
	[scrollView addSubview:calendarAppLabel];
	calendarAppLabel.text = @"Calendar";
	calendarAppLabel.textAlignment = UITextAlignmentCenter;
	calendarAppLabel.backgroundColor = [UIColor clearColor];
	
	UIButton *facultyAppButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	facultyAppButton.frame = CGRectMake(132, 130, 80, 80);
	[scrollView addSubview:facultyAppButton];
	[facultyAppButton addTarget:self action:@selector(OpenFacultyApp_iPad:) forControlEvents:UIControlEventTouchUpInside];
	
	UILabel *facultyAppLabel = UILabel.new;
	facultyAppLabel.frame = CGRectMake(132, 215, 80, 20);
	[scrollView addSubview:facultyAppLabel];
	facultyAppLabel.text = @"Faculty";
	facultyAppLabel.textAlignment = UITextAlignmentCenter;
	facultyAppLabel.backgroundColor = [UIColor clearColor];
	
	UIButton *studentActivitiesButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	studentActivitiesButton.frame = CGRectMake(238, 130, 80, 80);
	[scrollView addSubview:studentActivitiesButton];
	[studentActivitiesButton addTarget:self action:@selector(OpenStudentActivitiesApp_iPad:) forControlEvents:UIControlEventTouchUpInside];
	
	UILabel *studentActivitiesLabel = UILabel.new;
	studentActivitiesLabel.frame = CGRectMake(238, 215, 80, 20);
	[scrollView addSubview:studentActivitiesLabel];
	studentActivitiesLabel.text = @"Activities";
	studentActivitiesLabel.textAlignment = UITextAlignmentCenter;
	studentActivitiesLabel.backgroundColor = [UIColor clearColor];
}

- (IBAction)OpenMapApp_iPad:(id)sender
{
	NSLog(@"aaaaaaaaaaaa");
	[[self navigationController] pushViewController:mapAppViewController_iPad animated:YES];
}

- (IBAction)OpenWavenetApp_iPad:(id)sender
{
	NSLog(@"aaaaaaaaaaaa");
	[[self navigationController] pushViewController:wavenetAppViewController_iPad animated:YES];
}

- (IBAction)OpenCafeApp_iPad:(id)sender
{
	NSLog(@"aaaaaaaaaaaa");
	[[self navigationController] pushViewController:cafeAppViewController_iPad animated:YES];
}

- (IBAction)OpenLibraryApp_iPad:(id)sender
{
	NSLog(@"aaaaaaaaaaaa");
	[[self navigationController] pushViewController:libraryAppViewController_iPad animated:YES];
}

- (IBAction)OpenDivisionApp_iPad:(id)sender
{
	NSLog(@"aaaaaaaaaaaa");
	[[self navigationController] pushViewController:divisionAppViewController_iPad animated:YES];
}

- (IBAction)OpenAthleticsApp_iPad:(id)sender
{
	[[self navigationController] pushViewController:athleticsAppViewController_iPad animated:YES];
	
}

- (IBAction)OpenConvoApp_iPad:(id)sender
{
	[[self navigationController] pushViewController:convoAppViewController_iPad animated:YES];
	
}

- (IBAction)OpenCalendarApp_iPad:(id)sender
{
	[[self navigationController] pushViewController:calendarAppViewController_iPad animated:YES];
	
}

- (IBAction)OpenFacultyApp_iPad:(id)sender
{
	[[self navigationController] pushViewController:facultyAppViewController_iPad animated:YES];
	
}

- (IBAction)OpenStudentActivitiesApp_iPad:(id)sender
{
	[[self navigationController] pushViewController:studentActivitiesAppViewController_iPad animated:YES];	
}

- (IBAction)OpenTempApp_iPad:(id)sender
{
	NSLog(@"aaaaaaaaaaaa");
	[[self navigationController] pushViewController:tempAppViewController_iPad animated:YES];
}



- (void) pageTurn: (UIPageControl *) aPageControl
{
	int whichPage = aPageControl.currentPage;
	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:0.3f];
	[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
	scrollView.contentOffset = CGPointMake(768.0f * whichPage, 0.0f);
	[UIView commitAnimations];
}

- (void) scrollViewDidScroll: (UIScrollView *) aScrollView
{
	CGPoint offset = aScrollView.contentOffset;
	pageControl.currentPage = (offset.x + 384) / 768.0f;
}

- (void)dealloc {
    [super dealloc];
}






@end
